package com.example.filter;

import com.example.filter.util.RoundImage;
import ohos.aafwk.ability.AbilitySlice;
import ohos.agp.components.*;
import ohos.hiviewdfx.HiLog;
import ohos.hiviewdfx.HiLogLabel;
import java.util.List;

public class ThumbnailProvider extends BaseItemProvider {

    private static final HiLogLabel LABEL = new HiLogLabel(HiLog.DEBUG, 0, "THUMBNAILS_PROVIDER");
    private static final String TAG = "THUMBNAILS_PROVIDER";
    private static int lastPosition = -1;
    private List<ThumbnailItem> dataSet;
    private AbilitySlice slice;
    private Component mConvertView;


    public ThumbnailProvider(List<ThumbnailItem> dataSet, AbilitySlice slice) {
        this.dataSet = dataSet;
        this.slice = slice;
    }

    @Override
    public int getCount() {
        return dataSet.size();
    }

    @Override
    public Object getItem(int i) {
        return dataSet.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public Component getComponent(int i, Component component,
                                  ComponentContainer componentContainer) {
        final ThumbnailItem thumbnailItem = dataSet.get(i);
        component = LayoutScatter.getInstance(slice)
                    .parse(ResourceTable.Layout_list_thumbnail_item, null, false);
        RoundImage image = (RoundImage) component.findComponentById(ResourceTable.Id_thumbnail);
        image.setPixelMapAndCircle(thumbnailItem.image);
        return component;
    }


}
